package com.yanqu.xiuxian.config.elementalbonds;

import com.yanqu.xiuxian.config.annotations.ConfigFieldAnnotation;
import com.yanqu.xiuxian.config.annotations.ConfigFileAnnotation;
import com.yanqu.xiuxian.config.utils.excel.StringUtils;
import com.yanqu.xiuxian.utils.date.DateHelper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@ConfigFileAnnotation(fileName = "ElementalBondsSkill")
public class ElementalBondsSkillConfig {
    private int id;
    @ConfigFieldAnnotation(filedName = "price", parseMethod = "parsePrice")
    private Map<Integer, Integer> priceMap = new HashMap<>();
    private int itemId;
    @ConfigFieldAnnotation(filedName = "maxTime", parseMethod = "parseMaxTime")
    private long maxTime;
    private int open;

    @ConfigFieldAnnotation(filedName = "skillParam", parseMethod = "parseSkillParam")
    private List<Long> skillParamList;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public long getMaxTime() {
        return maxTime;
    }

    public void setMaxTime(long maxTime) {
        this.maxTime = maxTime;
    }

    public List<Long> getSkillParamList() {
        return skillParamList;
    }

    public void setSkillParamList(List<Long> skillParamList) {
        this.skillParamList = skillParamList;
    }

    public Map<Integer, Integer> getPriceMap() {
        return priceMap;
    }

    public void setPriceMap(Map<Integer, Integer> priceMap) {
        this.priceMap = priceMap;
    }

    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    public int getOpen() {
        return open;
    }

    public void setOpen(int open) {
        this.open = open;
    }

    public void parsePrice(String price) {
        if (price.equals("0")) return;
        String[] prices = price.split("\\|");
        for (String p : prices) {
            String[] priceInfo = p.split(",");
            priceMap.put(Integer.parseInt(priceInfo[1]), Integer.parseInt(priceInfo[0]));
        }
    }

    public void parseMaxTime(String maxTime) {
        this.maxTime = StringUtils.parseLong(maxTime) * DateHelper.SECOND_MILLIONS;
    }

    public void parseSkillParam(String str) {
        this.skillParamList = StringUtils.stringToLongList(str, "\\|");
    }
}
